Skip to content

feat: support plugin configuration in bsconfig and CLI#1706

Draft
TwitchBronBron wants to merge 2 commits into
masterfrom
plugin-configuration-support
Draft

feat: support plugin configuration in bsconfig and CLI#1706
TwitchBronBron wants to merge 2 commits into
masterfrom
plugin-configuration-support

Conversation

@TwitchBronBron
Copy link
Copy Markdown
Member

@TwitchBronBron TwitchBronBron commented May 12, 2026

Adds plugin configuration support to both bsconfig.json and the CLI, plus a new Plugin.onSetConfiguration(config) lifecycle hook that fires immediately after every plugin is loaded.

bsconfig.json

plugins entries can now be objects with src, name?, and config? (the previous string shorthand still works):

{
    "plugins": [
        "./scripts/myPlugin.js",
        { "src": "@rokucommunity/bslint", "name": "bslint", "config": "./bslint.jsonc" },
        { "src": "./scripts/custom.js", "config": { "severity": "error" } }
    ]
}

config is either an inline object or a path to a JSONC file (comments and trailing commas allowed).

CLI

Load and name with --plugin <src> [<name>] (repeatable):

bsc --plugin "@rokucommunity/bslint" bslint \
    --plugin ./scripts/custom.js house-rules

Override config with --plugin.<id>.<prop>=<value> (deep-merge):

bsc --plugin.bslint.severity=error --plugin.bslint.rules.no-print=off

Replace config entirely with a bare --plugin.<id>=<value> (no dotted path); if the value is a path, the JSONC file is loaded. Combinable with merge — replace is always applied first regardless of CLI order:

# Loads ./ci-bslint.jsonc as the whole config, then overrides `severity`
bsc --plugin.bslint=./ci-bslint.jsonc --plugin.bslint.severity=hint

Quoted segments anywhere in the dotted key handle ids/props containing dots:

bsc --plugin."my.module".enabled=false
bsc --plugin.bslint."rules.no-underscores"=warn

ID resolution

<id> is matched against loaded plugins with strict precedence — a higher-priority match wins outright, and lower-level collisions are ignored:

  1. bsconfig user-supplied name
  2. Plugin factory name
  3. bsconfig src (as written)

Ambiguity at the chosen level hard-fails with a message listing the conflicting plugins.

Full docs (with more examples) in docs/plugins.md.

🤖 Generated with Claude Code

Allow `plugins` entries in `bsconfig.json` to be objects with `src`,
optional `name`, and optional `config` (inline object or path to a JSONC
file) in addition to the existing string shorthand. Introduces a new
`Plugin.onSetConfiguration(config)` lifecycle hook that fires on every
plugin immediately after load. CLI flags of the form
`--plugin.<name>.<key>=<value>` deep-merge on top of the bsconfig
plugin config.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@markwpearce
Copy link
Copy Markdown
Collaborator

Should this be in v1?

If not, can we change some stuff to match what v1 is doing with plugins? For Example changing event names.. "onSetConfiguration" -> "setConfiguration" (verb_noun format)

… plugin overrides

- Pre-tokenize argv for --plugin <src> [<name>] pairs (yargs can't natively
  distinguish a name positional from another src in an array form).
- Add `pluginOverrides` runtime field with replace/merge semantics:
  bare --plugin.<id>=<value> fully replaces the bsconfig config (loading a
  JSONC file if the value is a path); --plugin.<id>.<prop>=<value> deep-merges.
- Resolve override identifiers with strict precedence: bsconfig user-supplied
  `name` → factory `name` → bsconfig `src`. A higher-priority match wins
  outright; ambiguity at the chosen level hard-fails with a clear message.
- Add a flat-key parser supporting double-quoted segments at any position
  so ids/props containing dots can be addressed without escaping.
- Document the new CLI behavior and naming precedence in docs/plugins.md.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment thread src/cli.ts
@@ -25,12 +28,7 @@ let options = yargs
.option('cwd', { type: 'string', description: 'Override the current working directory.' })
.option('copy-to-staging', { type: 'boolean', defaultDescription: 'true', description: 'Copy project files into the staging folder, ready to be packaged.' })
.option('diagnostic-level', { type: 'string', defaultDescription: '"warn"', description: 'Specify what diagnostic types should be printed to the console. Value can be "error", "warn", "hint", "info".' })
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to discuss this, because it's technically a breaking change to remove this alias.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants